<?php
    class ProjectController extends Main_Controller_Action
    {
        private $_arrParam;
        private $_model;
        
        public function init()
        {
            $this->loadTemplates();
            $this->_arrParam = $this->_request->getParams();
            $this->_model = new Default_Model_Project();
        }
        
        public function indexAction()
        {
            $this->view->headTitle('Nội thất Bảo Toàn - Dự án nội thất');
            $adapter = new Zend_Paginator_Adapter_DbSelect($this->_model->listItem());
            $paginator = new Zend_Paginator($adapter);
            $paginator->setDefaultItemCountPerPage(10);
            $paginator->setPageRange(5);
            $currentPage = $this->_request->getParam('page', 1);
            $paginator->setCurrentPageNumber($currentPage);
            $this->view->data = $paginator;
        }
        
        public function detailAction()
        {
            $id = (int) $this->_arrParam['id'];
            $this->view->data = $this->_model->getItem($id);
            $this->view->data2 = $this->_model->getListItemById($id);
            $this->view->headTitle('Nội thất Bảo Toàn - '.$this->view->data['title']);
        }
    }
